/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.benkyou.server.listeners;

import com.benkyou.common.Player;
import com.benkyou.common.messages.PlayerMessage;
import com.benkyou.common.messages.PlayerSyncMessage;
import com.benkyou.server.GameServer;
import com.jme3.network.Filters;
import com.jme3.network.HostedConnection;
import com.jme3.network.Message;
import com.jme3.network.MessageListener;
import java.util.ArrayList;

/**
 *
 * @author student
 */
public class PlayerMessageListener implements MessageListener<HostedConnection>{

    private GameServer gameServer;
    public PlayerMessageListener(GameServer gameServer) {
        this.gameServer = gameServer;
    }

    public void messageReceived(HostedConnection source, Message m) {
       if(m instanceof PlayerMessage){
           PlayerMessage playerMessage = (PlayerMessage) m;
           if(playerMessage.isMove()){
               gameServer.getMyServer().broadcast(Filters.notEqualTo(source), playerMessage);
     
           }
       }
    }
    
}
